package com.liuhuxiang.order.controller;

import com.liuhuxiang.order.feign.ProductFeignService;
import com.liuhuxiang.order.feign.StockFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 新建订单服务
 *
 * @author liuhuxiang
 * @version: OrderController.java, 2023年02月27日 下午12:13 liuhuxiang  Exp $
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    //注入刚定义的stockFeignService
    @Autowired
    StockFeignService stockFeignService;

    //注入刚定义的productFeignService
    @Autowired
    ProductFeignService productFeignService;

    @RequestMapping("/add")
    public String add() {
        System.out.println("下单成功");


/*     //我需要在这里去调用stock的远程接口，通过RestTemplate
       //getForObject 的参数 1 远程调用地址   2 响应参数的类型   3入参的类型   本接口没有入参，只要两个参数即可
       String msg = restTemplate.getForObject("http://stock-service/stock/reduct", String.class);
 */

        String msg = stockFeignService.reduct();

        String product = productFeignService.get(1);

        return "Hello Feign" + msg + product;
    }

}